package com.isay.frameworklib.okhttp;

import com.isay.frameworklib.user.UserManager;

import java.io.IOException;
import java.util.UUID;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 统一添加鉴权、Header信息
 */
public class RequestInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        //添加Header信息
        Request.Builder builder = chain.request().newBuilder();
        builder.addHeader("Cookie", "PHPSESSID=" + UserManager.getPHPSESSID());
        builder.addHeader("content-type", "application/x-www-form-urlencoded");
        Request request = builder.build();
        return chain.proceed(request);
    }

}
